﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prism.Games.GalEngine.Scripts.Parser
{
    public class LogManager
    {
        public LogManager(ScriptParser parser)
        {
            this.Parser = parser;
            this.LogScenes = new Data.ResourceCollection.SceneCollection();
        }

        public ScriptParser Parser;

        public Prism.Games.GalEngine.Scripts.Data.ResourceCollection.SceneCollection LogScenes;

        public void ShowLogFrame()
        {
            this.Parser.SecondTierGUIState = SecondTierGUIState.Log;

            this.Parser.GraphicBase.GameWindow.SetSecondContent(this.Parser.GraphicBase.GalUIFrame.LogFrame);

            var listBox = this.Parser.GraphicBase.GameWindow.FindSecondName(GameFrameLibrary.Strings.LogListBox) as System.Windows.Controls.ListBox;

            this.LogScenes.Clear();

            for (int i = 0; i < this.Parser.SaveDataManager.SaveState.Section.Scenes.Count; i++)
            {
                var x = this.Parser.SaveDataManager.SaveState.Section.Scenes[i];

                if (i <= this.Parser.SaveDataManager.SaveState.Section.Scenes.IndexOf(this.Parser.SaveDataManager.SaveState.Scene))
                {
                    this.LogScenes.Add(x);
                }
            }

            listBox.ItemsSource = this.LogScenes;

            this.Parser.GraphicBase.PlaySecondAnimation(GameFrameLibrary.Strings.LogFadeIn, null);

            this.Parser.TierState |= TierState.Second;
        }
    }
}
